#ifndef TENSOR_H
#define TENSOR_H
#include <iostream>

// 张量形状(z, y, x)
typedef struct {
    int x = 1;
    int y = 1;
    int z = 1;
}Shape;

class Tensor{
    public:
        Tensor();
        Tensor(Shape shape, int seed);
        Tensor(Shape shape, float *data); // 自定义输入数据
        Shape shape; // 张量形状
        float *data; //数据,
        
        void print_shape(); //打印张量形状
        void t(); // 矩阵转置,将原始矩阵直接转置
        Tensor *T(); // 转置,将原始矩阵转置后赋值给新矩阵
        void print_data(); // 打印张量数据
};

Tensor *tensorMalloc(Shape shape, float *data, int seed);
void tensorFree(Tensor *a);
Tensor *tensor_add(Tensor *a, Tensor *b);
Tensor *tensor_sub(Tensor *a, Tensor *b);
Tensor *tensor_matmul(Tensor *a, Tensor *b);
Tensor *tensor_mul(float a, Tensor *b);
Tensor *mabs(Tensor *a);
Tensor *cps(Tensor *a, int dim, int num); // 以指定的维度进行扩展数据
Tensor *tensor_mean(Tensor *a, int dim);
Tensor *tensor_sum(Tensor *a, int dim);
Tensor *zeros(Shape shape);
Tensor *ones(Shape shape);
Tensor *tensorCopy(Tensor *x);
// int data_size(Tensor *x);
Tensor *flat(Tensor *x, int dim);

#endif // TENSOR_H